package com.difsonapps.android.marker.services;

import com.difsonapps.android.marker.activities.LoginActivity;

import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class AccountAuthenticator extends AbstractAccountAuthenticator{
	public static final String KEY_AUTHENTICATION_ORIGIN = "authentication_origin";
	public static final String AUTHENTICATION_SERVICE = "authentication_service";
	
	public static final String KEY_AUTHTOKEN_TYPE = "authtoken_type";
	public static final String ACCOUNT_TYPE = "com.difsonapps.android.markit";
	Context context;
	public AccountAuthenticator(Context context) {
		super(context);
		this.context = context;
		// TODO Auto-generated constructor stub
	}

	@Override  
	public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)  
	    throws NetworkErrorException {  
	    
	  final Bundle result;  
	  final Intent intent;  
	                  
	  intent = new Intent(this.context, LoginActivity.class);  
	  //intent.putExtra(Constants.AUTHTOKEN_TYPE, authTokenType);  
	  intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
	  intent.putExtra(KEY_AUTHENTICATION_ORIGIN, AUTHENTICATION_SERVICE);
	  
	  result = new Bundle();  
	  result.putParcelable(AccountManager.KEY_INTENT, intent);  
	          
	  return result;  
	} 

	@Override
	public Bundle confirmCredentials(AccountAuthenticatorResponse response,
			Account account, Bundle options) throws NetworkErrorException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Bundle editProperties(AccountAuthenticatorResponse response,
			String accountType) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Bundle getAuthToken(AccountAuthenticatorResponse response,
			Account account, String authTokenType, Bundle options)
			throws NetworkErrorException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getAuthTokenLabel(String authTokenType) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Bundle hasFeatures(AccountAuthenticatorResponse response,
			Account account, String[] features) throws NetworkErrorException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Bundle updateCredentials(AccountAuthenticatorResponse response,
			Account account, String authTokenType, Bundle options)
			throws NetworkErrorException {
		// TODO Auto-generated method stub
		return null;
	}

}
